home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Graphics Plus
/
Graphics Plus.iso
/
msdos
/
viewers
/
hv12
/
src
/
fnsplit.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-07-05
|
1KB
|
68 lines
#include <strings.h>
#include <stdlib.h>
#include <stdio.h>
void
fnsplit (char *path, char *drive, char *dir, char *name, char *ext)
{
char temppath[128];
char *cptr, *p1, *p2, *p3;
*(ext++) = '.';
strcpy (temppath, path);
cptr = strtok (temppath, " :");
p1 = strtok (NULL, ":");
if (p1 == NULL)
{
*drive = '\0';
p1 = temppath;
}
else
{
*drive = *cptr;
*(drive + 1) = ':';
}
strcpy (temppath, path);
p2 = p1;
p3 = p1;
while (*p2 != '\0')
{
if (*p2 == '\\')
p3 = p2;
p2++;
}
p2 = p1;
while (p2 != p3)
*(dir++) = *(p2++);
if (p2 != p1)
{
*(dir++) = '\\';
p3++;
}
*dir = '\0';
while ((*p3) != '.' && (*p3) != '\0')
*(name++) = *(p3++);
*name = '\0';
if (*(p3++) == '.')
while (*p3 != NULL)
*(ext++) = *(p3++);
*ext = '\0';
}
/*
main(int argc,char **argv)
{
char hell[100];
char drive[10];
char dir[50];
char name[50];
char ext[10];
fnsplit(argv[1],drive,dir,name,ext);
printf("%s %s %s %s\n",drive,dir,name,ext);
}
*/